package InsLoginRegister;

public class count {
    java.sql.Connection conn = null;
    String strConn;
    java.sql.Statement sqlStmt1 = null,sqlStmt2 = null,sqlStmt3= null,sqlStmt4 = null,sqlStmt5=null,sqlStmt6=null;
    java.sql.ResultSet sqlRst1=null,sqlRst2=null,sqlRst3=null,sqlRst4= null,sqlRst5=null,sqlRst6=null;
    public void sort(int A[])
    {
        try
        {
            Class.forName("org.h2.Driver");
            conn = java.sql.DriverManager.getConnection("jdbc:h2:~/jpa-demo-db;MODE=MYSQL;DB_CLOSE_DELAY=-1", "sa", "sa");
            sqlStmt1 = conn.createStatement();
            sqlStmt2 = conn.createStatement();
            sqlStmt3 = conn.createStatement();
            sqlStmt4 = conn.createStatement();
            sqlStmt5 = conn.createStatement();
            sqlStmt6 = conn.createStatement();
            String sql1 = "select count(*)as cus from customer";
            String sql2= "select count(*)as man from manager";
            String sql3= "select count(*)as ro from room";
            String sql4 ="select sum(pledge)as zc from order1";
            String sql5 = "select sum(pledge+price)as sr from order1";
            String sql6 = "select count(*)as or from order1";
            sqlRst1 = sqlStmt1.executeQuery(sql1);
            if(sqlRst1.next()) A[0]=sqlRst1.getInt("cus");
            sqlRst2 = sqlStmt2.executeQuery(sql2);
            if(sqlRst2.next()) A[1]=sqlRst2.getInt("man");
            sqlRst3=sqlStmt3.executeQuery(sql3);
            if(sqlRst3.next()) A[2] = sqlRst3.getInt("ro");
            sqlRst4=sqlStmt4.executeQuery(sql4);
            if(sqlRst4.next()) A[3] = sqlRst4.getInt("zc");
            sqlRst5=sqlStmt5.executeQuery(sql5);
            if(sqlRst5.next()) A[4] = sqlRst5.getInt("sr");
            sqlRst6=sqlStmt6.executeQuery(sql6);
            if(sqlRst6.next()) A[5] = sqlRst6.getInt("or");
    }
        catch (Exception ex)
        {
            System.out.println(ex.toString());
        }
    }
}
